import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Demo1 {
    //?????????????????????в?????????
    public static void main(String[] args) throws SQLException {
        //1.?????DataSource
        DataSource dataSource=new MysqlDataSource();

        ((MysqlDataSource)dataSource).setUrl( "jdbc:mysql://127.0.0.1:3306/java109?characterEncoding=utf8&useUnicode=true&useSSL=false");
        ((MysqlDataSource)dataSource).setUser("root");
        ((MysqlDataSource)dataSource).setPassword("root");
        Connection connection= dataSource.getConnection();
        String sql="insert into student values(3,'中午')";
        PreparedStatement statement=connection.prepareStatement(sql);
        int n=statement.executeUpdate();
        System.out.println("n= "+n);
        statement.close();
        connection.close();
    }
}
